<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>北京航天公司固定资产管理系统</title>

    <style>
        header {
            background-color:#339966;
            color:white;
            text-align:center;
            padding:5px;
        }
        section {
            width:350px;
            float:left;
            padding:10px;
        }
        footer {
            background-color:#339966;
            color:white;
            clear:both;
            text-align:center;
            padding:5px;
        }
    </style>
</head>
<body>

<div class="layui-inline">
    <div class="layui-col-xs6 layui-col-md4">
        <blockquote class="layui-elem-quote" style="width: 1550px;">资产领用归还详情页面</blockquote><br>
    </div>
</div>
<section>
    <form action="javascript:void(0)" class="layui-form" id="from">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">所属组织</label>
                <div class="layui-input-inline">
                    <select name="homeOrgan"  lay-filter="mySelect">
                        <option value="">--请选择--</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">所属部门/门店</label>
                <div class="layui-input-inline">
                    <select name="depa"  lay-filter="mySelects">
                        <option value="">--请选择--</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">责任人</label>
                <div class="layui-input-inline">
                    <input type="text"  name="admin" lay-verify="title" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">调用物品</label>
            <div class="layui-input-block" id="propertyDiv">

            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">申请说明</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" nameo="purpose" name="purpose"  class="layui-textarea"></textarea>
            </div>
        </div>


    </form>
    <button onclick="addByClaim()" class="layui-btn">提交</button>
    <button onclick="back()" class="layui-btn">返回</button>


</section>



</body>
<script type="text/javascript"  src="/js/jquery-1.8.2.js"></script>
<script type="text/javascript"  src="/js/layer.js"></script>
<script type="text/javascript"  src="/layui/layui.all.js" ></script>
<link rel="stylesheet" href="/layui/css/layui.css">
<script>
    var form=layui.form;
    $(function(){
        InitProv();
        form.on('select(mySelect)',function(object){
            $.post("/claim/departmentByParentId?parentId="+object.value,function(res){
                for (var i = 0; i < res.length; i++) {
                    $("select[name='depa']").append('<option value="'+res[i].did+'">'+res[i].dname+'</option>')
                }
                form.render();
            },'json')
        })
        //监控lay-filter=mySelects
        form.on('select(mySelects)',function(object){
            var id = $("select[name='depa']").val()
            console.log(id);
            $("#propertyDiv").empty();
            $.post('/claim/findByProperId?property_dep_id='+id,function (res) {
                console.log(res)
                for (var i in res) {
                    $("#propertyDiv").append("<input type='checkbox' name='property_id' id='property_id'  value='"+res[i].property_id+"' title='"+res[i].property_name+"'>");
                }
                form.render();
            },"json")
        })
    })
    function InitProv() {
        $.post("/claim/departmentByParentId?parentId=0",function (res) {
            for (var i = 0; i <res.length ; i++) {
                $("select[name='homeOrgan']").append("<option value='"+res[i].did+"'>"+res[i].dname+"</option>");
            }
            form.render();
        },"json")
    }
    function addByClaim(){
        var data=$("#from").serialize();
        console.log(data);
        $.post("/claim/insertByDepProMidd",data,function(request){
            if(request =="ok"){
                alert("申请成功，请去主页面查看状态")
                location.href = "/jump/goclaimIndex";
            }else{
                alert("申请失败，刷新服务器重试")
            }
        })
    }

    function back(){
        window.location.href="/jump/goclaimIndex";
    }
</script>
</html>